package com.cheng.student.controller.servlet;

import com.cheng.student.service.StudentServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
//1
@WebServlet(name = "ChangeStudentServlet", value = "/teacher/ChangeStudentServlet")
public class ChangeStudentServlet
        extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        String name = request.getParameter("name");
        String examNumber = request.getParameter("examNumber");
        String key = request.getParameter("key");
        String value = request.getParameter("value");
        //校验
        if(name == null||examNumber == null||key == null||value == null)
        {
            response.getWriter().write("信息有误");
            return;
        }
        if("".equals(name)||"".equals(examNumber)||"".equals(key)||"".equals(value))
        {
            response.getWriter().write("信息有误");
            return;
        }
        //通过
        StudentServiceImpl studentService = new StudentServiceImpl();

        boolean b = studentService.updateStudentFull(name, examNumber, key, value);
        if (b)
        {

        }
        else
        {
            response.getWriter().write("更改失败");
            return;
        }
        response.getWriter().write("更改成功");
    }
}
